<?php
ini_set('display_errors',1);            //错误信息
ini_set('display_startup_errors',1);    //php启动错误信息
error_reporting(-1);                    //打印出所有的 错误信息
ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); //将出错信息输出到一个文本文件
//构造函数，获取Access Token
require dirname(__FILE__).'/init.inc.php';
require_once dirname(__FILE__).'/smarty.inc.php';
require_once 'action/LikeAction.class.php';
global $wechatObj;
global $smarty;
$js_sdk = new JSSDK(APPID,APPSECRET,$wechatObj->access_token);
$model = new UserModel();
$action = new LikeAction($smarty, $js_sdk,$model);
echo "<h2>活动已结束</h2>";
/*
if(isset($_GET['code'])){
    $code = $_GET['code'];
    $result = $wechatObj->getOpenIdByCode($code);
    if(!empty($result)){
        $like_person_openid = $result['openid'];
        $action->like_person_openid = $like_person_openid;
        if(!empty($_GET['state'])){
            $openid = $_GET['state'];
            if($id = $action->existsOpenid($openid)){
                $user = $action->getOneUser($id);
                $action->bei_like_openid = $user->openid;
                $action->name = $user->name;
                // 存在
                $action->action();
            }else{
                // 不存在
                header("Location:ac_index.php");
            }
        }
    }

}else{
    // 点赞
    if(!empty($_POST['like_person_openid']) && !empty($_POST['bei_like_openid']) ){
        $like_person_openid = $_POST['like_person_openid'];
        $bei_like_openid = $_POST['bei_like_openid'];
        $action->addLike($like_person_openid,$bei_like_openid);
    }
    // 跳到主页面
    header("Location:ac_index.php");
}
*/
?>
